{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ad2b81fd-249f-49ff-b780-9ca25c863108",
   "metadata": {},
   "source": [
    "deepseek自动的代码还是太难受了……这里试试手动操作一点  \n",
    "热容的话，相当于斜率吧，然后根据热力学以变化为研究单位，或许能整点东西出来？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "id": "9143bebb-a7ff-48d4-bcd6-ce8b2c9eff51",
   "metadata": {},
   "outputs": [],
   "source": [
    "class ReSystem: #热力学系统\n",
    "    def __init__(self,U=var('U')):\n",
    "        self.U=U\n",
    "        # p T V都只是表观，热容好像也只是其中一种？\n",
    "        # 用内能来的话会不会好一点？\n",
    "    #以黑盒子的认识方式\n",
    "    def give_re(Q): #系统吸热，如果Q为负值则是放热，\n",
    "        # 吸热后的反应，有等容，等压\n",
    "        U+=Q\n",
    "    def give_gong(A): #对系统做功\n",
    "        U+=A\n",
    "\n",
    "    # 然而热力学还有考虑孤立系统、封闭系统、开放系统\n",
    "    # 不过绝热的话可能和下面这个tau重复了？\n",
    "    # 只是话说回来，“可逆绝热”是修饰“过程”的，而孤立、封闭则是修饰系统的……应该能有代表作用吧？"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3f4e73fd-2c0e-4d9c-979c-0d15e1c309a0",
   "metadata": {},
   "source": [
    "理想气体\n",
    "$$\n",
    "pV^\\tau = 常量, \\quad TV^{\\tau-1}=常量, \\quad Tp^{(\\frac 1 \\tau -1)}=常量\n",
    "$$\n",
    "其中，绝热$\\tau = C_p/C_V $，等压$\\tau=0$，等容$\\tau=\\infty$，等温$\\tau=1$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "id": "dc991e77-0c3c-472c-ad1a-b58d94121025",
   "metadata": {},
   "outputs": [],
   "source": [
    "class IdealGas(ReSystem): # 理想气体\n",
    "    def __init__(self,U=var('U'),p=var('p'),V=var('V'),T=var('T'),tau=1):\n",
    "        super(IdealGas, self).__init__(U)\n",
    "        self.p=p\n",
    "        self.V=V\n",
    "        self.T=T\n",
    "        self.tau=tau \n",
    "        #不同的tau代表不同的过程，绝热的为Cp/CV\n",
    "        #等压0，等温1，等容无穷大\n",
    "        # 然而tau好像更像是一种外部控制？\n",
    "    def change_p(self,dp=0):\n",
    "        # tau=0为等压，不可用\n",
    "        self.V=self.V*((self.p+dp)/self.p)^(1/self.tau)\n",
    "        self.T=self.T*((self.p+dp)/self.p)^(1/self.tau -1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 116,
   "id": "6639164d-3904-4725-8937-d74275570505",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\frac{3}{2} \\, V\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle \\frac{3}{2} \\, V$"
      ],
      "text/plain": [
       "3/2*V"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle T\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle T$"
      ],
      "text/plain": [
       "T"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 表述一个理想气体等容升温过程？（压强要跟着升高）\n",
    "idg = IdealGas(p=2,tau=1)\n",
    "idg.change_p(1)\n",
    "show(idg.V)\n",
    "show(idg.T)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "362dbff0-9880-4f17-b0b1-d2a495cc8b51",
   "metadata": {},
   "source": [
    "但是热容好像还没整出来"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "id": "40bc23cd-bc8c-4c44-8bdd-36f51a2e69c2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 110,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "infinity==infinity+1 #python有直接的“无限”的表示，还是可以的\n",
    "#但好像处理不好……或者说等容这里的式子实在没法整？\n",
    "#好像通用解确实整不了……solve整不了无限，但手动可以整无限"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ae581f7d-0497-4b7a-9f47-7a6b3505d3d1",
   "metadata": {},
   "source": [
    "书上说，第一定律两种形式：“微分”（元过程）与积分（两平衡态之间）  \n",
    "本质上差不多吧……元过程相当于给个斜率关系，积分的就是实际应用的了"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "SageMath 10.5",
   "language": "sage",
   "name": "sagemath"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
